<template>
  <div class="left-menu">
    <el-menu
        class="el-menu-vertical-demo"
        :default-active="path"
        @open="handleOpen"
        @close="handleClose"
        router
    >
        <el-menu-item index="/">
          <i class="el-icon-s-home"></i>
          <span slot="title">后台首页</span>
        </el-menu-item>
        <el-submenu index="1">
          <template slot="title">
            <i class="el-icon-s-shop"></i>
            <span>商品管理</span>
          </template>
          <el-menu-item index="/firstTypeList" v-if="user_state == 1">公司列表</el-menu-item>
          <el-menu-item index="/secondTypeList">品牌系列</el-menu-item>
          <el-menu-item index="/goodsList">款式库存</el-menu-item>
          <el-menu-item index="/contentList">内容中心</el-menu-item>
        </el-submenu>
        <el-menu-item index="/userList" v-if="user_state == 1">
          <i class="el-icon-s-marketing"></i>
          <span slot="title">用户列表</span>
        </el-menu-item>
        <el-menu-item index="/comment">
          <i class="el-icon-s-comment"></i>
          <span slot="title">评论列表</span>
        </el-menu-item>
        <el-submenu index="4">
          <template slot="title">
            <i class="el-icon-s-management"></i>
            <span>订单管理</span>
          </template>
          <el-menu-item index="/orderList">盲盒订单</el-menu-item>
          <el-menu-item index="/rechargeOrderList">充值订单</el-menu-item>
          <el-menu-item index="/sendOrderList">发货订单</el-menu-item>
          <el-menu-item index="/Freight">支付运费列表</el-menu-item>
        </el-submenu>
        <el-submenu index="5" >
          <template slot="title">
            <i class="el-icon-s-flag"></i>
            <span>活动管理</span>
          </template>
          <el-menu-item index="/activity">活动推荐</el-menu-item>
          <el-menu-item index="/mealList" v-if="user_state == 1">活动列表</el-menu-item>
          <el-menu-item index="/RandomList" v-if="user_state == 1">随机活动</el-menu-item>
          <el-menu-item index="/rechargeList" v-if="user_state == 1">充值金额列表</el-menu-item>
        </el-submenu>
        <el-submenu index="6" v-if="user_state == 1">
          <template slot="title">
            <i class="el-icon-user-solid"></i>
            <span>账号管理</span>
          </template>
          <el-menu-item index="/number"> 账号列表</el-menu-item>
        </el-submenu>
        <el-menu-item v-if="user_state != 1" index="/personalinfo">
          <i class="el-icon-user-solid"></i>
          <span slot="title">个人中心</span>
        </el-menu-item>
        <!-- <el-submenu index="6" v-if="user_state != 1">
          <template slot="title">
            <i class="el-icon-s-management"></i>
            <span>个人中心</span>
          </template>
          <el-menu-item index="/changepassword"> 修改密码</el-menu-item>
          <el-menu-item index="/certification"> 审核认证</el-menu-item>
          <el-menu-item index="/personalinfo"> 个人资料</el-menu-item>
        </el-submenu> -->
        <el-submenu index="7" v-if="user_state == 1">
          <template slot="title">
            <i class="el-icon-success"></i>
            <span>审核列表</span>
          </template>
          <el-menu-item index="/brandreview"> 品牌系列</el-menu-item>
          <el-menu-item index="/contentreview"> 内容中心</el-menu-item>
          <el-menu-item index="/certificationaudit"> 设计师/渠道认证</el-menu-item>
        </el-submenu>
        <el-submenu index="8">
          <template slot="title">
            <i class="el-icon-s-management"></i>
            <span>财务管理</span>
          </template>
          <el-menu-item v-if="user_state == 1" index="/userBalanceList">财务统计列表</el-menu-item>
          <el-menu-item v-if="user_state != 1" index="/financialstatistics"> 财务统计</el-menu-item>
          <el-menu-item v-if="user_state == 1" index="/accountsettings"> 账户管理</el-menu-item>
        </el-submenu>
      </el-menu>
  </div>
</template>p

<script>
  export default {
    name: 'LeftMenu',
    computed: {
      //  获取顶层路由
      path() {
        let path = this.$route.path
        const index = path.indexOf('/')
        const nextIndex = path.indexOf('/', index + 1)
        return nextIndex != -1 ? path.substring(0, nextIndex) : path
      }
    },
    data(){
      return{
        user_state:localStorage.getItem('user_state')
      }
    },
    methods: {
      handleOpen(){},
      handleClose(){}
    }
  }
</script>

<style lang="scss">
  .left-menu {
    width: 280px;
  }
</style>
